#region imported Namespaces
using System;
using System.Data;

using BO = PHSRAG.Insight21.BusinessObjects;
using ICachePolicy = PHSRAG.Insight21.Policy.ICachePolicy;
#endregion

namespace PHSRAG.Insight21.Personnel
{
	#region Class Monthly Labor Distribution
	/// <summary>
	/// The MonthlyLaborDistribution class is the facade over the monthly payroll expense details for a single employee
	/// </summary>
	public class MonthlyLaborDistribution : BO.BusinessObject
	{
		#region Constants
		private const string MonthlyLaborDistributionKey		= "MonthlyLaborDistribution_AF881D62-8757-4c0d-A212-DD6E7DD667BE";
		//Constants to hold the column names
		private const string PersonIdColumnName			= "PersonId";
		private const string FirstNameColumnName		= "FirstName";
		private const string LastNameColumnName			= "LastName";
		private const string Month1ColumnName			= "Month1";
		private const string Month2ColumnName			= "Month2";
		private const string Month3ColumnName			= "Month3";
		private const string Month4ColumnName			= "Month4";
		private const string Month5ColumnName			= "Month5";
		private const string Month6ColumnName			= "Month6";
		private const string Month7ColumnName			= "Month7";
		private const string Month8ColumnName			= "Month8";
		private const string Month9ColumnName			= "Month9";
		private const string Month10ColumnName			= "Month10";
		private const string Month11ColumnName			= "Month11";
		private const string Month12ColumnName			= "Month12";
		private const string TotalColumnName			= "Total";
		#endregion
		
		#region Instance variables
		private DataRow distributionRow;
		#endregion

		#region Public properties

		/// <summary>
		/// Get the PersonId.
		/// </summary>
		public int PersonId 
		{
			get 
			{ 
				return (int)distributionRow[PersonIdColumnName]; 
			}
		}

		/// <summary>
		/// Get the first name of the employee
		/// Return an empty string if there is no name for the employee
		/// </summary>
		public string FirstName
		{
			get
			{
				object firstName = distributionRow[FirstNameColumnName];
				return (firstName == DBNull.Value)?string.Empty:firstName.ToString();
			}
		}

		/// <summary>
		/// Get the last name of the employee
		/// Return an empty string if there is no name for the employee
		/// </summary>
		public string LastName
		{
			get
			{
				object lastName = distributionRow[LastNameColumnName];
				return (lastName == DBNull.Value)?string.Empty:lastName.ToString();
			}
		}

		/// <summary>
		/// Get the amount of money the employee was paid for Month1
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month1
		{
			get
			{
				object month1 = distributionRow[Month1ColumnName];
				return (month1 == DBNull.Value)?string.Empty:month1.ToString();
			}
		}

		/// <summary>
		/// Get the amount of money the employee was paid for Month2
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month2
		{
			get
			{
				object month2 = distributionRow[Month2ColumnName];
				return (month2 == DBNull.Value)?string.Empty:month2.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month3
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month3
		{
			get
			{
				object month3 = distributionRow[Month3ColumnName];
				return (month3 == DBNull.Value)?string.Empty:month3.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month4
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month4
		{
			get
			{
				object month4 = distributionRow[Month4ColumnName];
				return (month4 == DBNull.Value)?string.Empty:month4.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month5
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month5
		{
			get
			{
				object month5 = distributionRow[Month5ColumnName];
				return (month5 == DBNull.Value)?string.Empty:month5.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month6
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month6
		{
			get
			{
				object month6 = distributionRow[Month6ColumnName];
				return (month6 == DBNull.Value)?string.Empty:month6.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month7
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month7
		{
			get
			{
				object month7 = distributionRow[Month7ColumnName];
				return (month7 == DBNull.Value)?string.Empty:month7.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month8
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month8
		{
			get
			{
				object month8 = distributionRow[Month8ColumnName];
				return (month8 == DBNull.Value)?string.Empty:month8.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month9
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month9
		{
			get
			{
				object month9 = distributionRow[Month9ColumnName];
				return (month9 == DBNull.Value)?string.Empty:month9.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month10
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month10
		{
			get
			{
				object month10 = distributionRow[Month10ColumnName];
				return (month10 == DBNull.Value)?string.Empty:month10.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month11
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month11
		{
			get
			{
				object month11 = distributionRow[Month11ColumnName];
				return (month11 == DBNull.Value)?string.Empty:month11.ToString();
			}
		}
		/// <summary>
		/// Get the amount of money the employee was paid for Month12
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Month12
		{
			get
			{
				object month12 = distributionRow[Month12ColumnName];
				return (month12 == DBNull.Value)?string.Empty:month12.ToString();
			}
		}

		/// <summary>
		/// Get the total amount of money the employee was paid for the period.
		/// Return an empty string if there is no pay amount
		/// </summary>
		public string Total
		{
			get
			{
				object total = distributionRow[TotalColumnName];
				return (total == DBNull.Value)?string.Empty:total.ToString();
			}
		}
		#endregion

		#region Constructor
		/// <summary>
		/// Initialize the base class with the specified cache policy and assign the DataRow to the instance variable
		/// </summary>
		/// <param name="cachePolicy">Prevalent cache policy</param>
		/// <param name="dataRow">DataRow containing Monthly Labor distribution data</param>
		public MonthlyLaborDistribution(ICachePolicy cachePolicy,DataRow dataRow):base(cachePolicy)
		{
			distributionRow = dataRow;
		}
		#endregion

		#region BusinessObject Methods
		/// <summary>
		/// Cache the MonthlyLaborDistribution instance using the prevalent cache policy
		/// </summary>
		public override void Cache()
		{
			CachePolicy.Cache(MonthlyLaborDistributionKey,this);
		}
		/// <summary>
		/// Remove the MonthlyLaborDistribution instance from the cache using the prevalent cache policy
		/// </summary>
		public override void UnCache()
		{
			CachePolicy.UnCache(MonthlyLaborDistributionKey);
		}
		/// <summary>
		/// This method is not used and only exists to satisfy interface requirements.
		/// </summary>
		public override void Load(string connectionString, params object[] args)
		{			
			throw new Exception("Monthly Labour distribution cannot be directly loaded.");
		}
		#endregion
	}
	#endregion
}